<template>

	<!-- 	<view class="">
		<van-search v-model="value" shape="round" background="#f7cb50" :autofocus="true" :clearable="false" show-action
			placeholder="搜索" @search="onSearch" @cancel="onCancel" />
		<view class="record">
			<view class="hotSearch">
				热门搜索
			</view>
			<view class="hotRecords">
				<text class="hotRecord" v-for="(item,index) in items" :key="index">
					{{item}}

				</text>
			</view>
		</view>
	</view> -->

	<view>
		<!-- 		<view class="" style="height: 20rpx;">

		</view> -->
		<zy-search :is-focus="false" :theme="themeClass" :show-want="true" :speechEngine="speechEngine"
			:hot-list="hotList" @getSearchText="getSearchText" @cancel="cancel" @search1="search1" @search2="search2"
			@clear="clear" :educationList="educationList" :noticeList="noticeList">
		</zy-search>
	</view>

</template>

<script>
	import zySearch from "@/components/zy-search/zy-search.vue"
	import {
		getPageEducationList,
		getPageNoticeList
	} from "@/api/home/home.js"
	export default {
		components: {
			zySearch
		},
		data() {
			return {
				themeClass: 'block',
				speechEngine: 'baidu', //语音识别引擎
				hotList: ['政策', '学习方法', '教育方法', '放假通知'], //初始化推荐列表
				educationList: [],
				noticeList: [],
				educationQueryParams: {
					pageSize: 10,
					pageNum: 1,
					educationTitle: null
				},
				noticeQueryParams: {
					pageSize: 10,
					pageNum: 1,
					noticeTitle: null
				}
			}
		},
		methods: {
			clear() {
				this.educationList = []
				this.noticeList = []
				this.educationQueryParams.pageNum = 1
				this.noticeQueryParams.pageNum = 1
			},
			search1(searchText) {
				console.log(searchText);
				this.educationQueryParams.educationTitle = searchText
				getPageEducationList(
					this.educationQueryParams
				).then(res => {
					if (res.code == 200) {
						this.educationList = res.rows;
					}
				})
			},
			search2(searchText) {
				this.noticeQueryParams.noticeTitle = searchText
				getPageNoticeList(
					this.noticeQueryParams
				).then(res => {
					if (res.code == 200) {
						// console.log(res);
						this.noticeList = res.rows;
					}
				})

			},
			cancel() {
				uni.navigateBack()
			},
			// getSearchText(e) {
			// 	uni.showToast({
			// 		title: '回调的搜索信息: ' + e,
			// 		icon: "none"
			// 	})
			// }
		},
	}
	// export default {
	// 	data() {
	// 		return {
	// 			items: ['作业', '数学', '复习方法', '校运会', '领导', '通知'],
	// 			value: ''
	// 		};
	// 	},
	// 	methods: {
	// 		onSearch(val) {

	// 		},
	// 		onCancel() {
	// 			uni.navigateBack()
	// 		}
	// 	}
	// }
</script>

<style lang="scss">
	// .van-search__action {
	// 	color: #ffffff;
	// }

	// .record {
	// 	margin-top: 30rpx;
	// 	background-color: #fff;
	// 	font-size: 25rpx;

	// 	.hotSearch {
	// 		padding-left: 15rpx;
	// 		padding-top: 10rpx;
	// 		padding-bottom: 10rpx;
	// 		border-bottom: 1px solid #dcdcdc;
	// 	}

	// 	.hotRecords {
	// 		margin-top: 10rpx;
	// 		padding-bottom: 10rpx;
	// 		display: flex;
	// 		justify-content: space-around;

	// 		.hotRecord {
	// 			display: inline-block;
	// 			padding: 15rpx;
	// 			border: 1px solid #dcdcdc;
	// 			border-radius: 10rpx;
	// 		}
	// 	}
	// }
</style>
